package vn.vnvas.xoso.utils;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

public class WebService_TuongThuat {

	private final String SOAP_ADDRESS = "http://115.84.179.72/wsxoso/Service.asmx";

	public String WsGETKETQUA(String method_name) {
		final String SOAP_ACTION = "http://tempuri.org/" + method_name;
		final String METHOD_NAME = method_name;
		final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";

		SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, METHOD_NAME);

		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		envelope.dotNet = true;

		envelope.setOutputSoapObject(request);

		HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
		Object response = null;
		try {
			httpTransport.call(SOAP_ACTION, envelope);
			response = envelope.getResponse();
		} catch (Exception exception) {
			response = exception.toString();
		}
		return response.toString();
	}
	
	public String WsGETKETQUATRUNGNAM(String method_name, String pi_name, String pi_value ) {
		final String SOAP_ACTION = "http://tempuri.org/" + method_name;
		final String METHOD_NAME = method_name;
		final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";

		SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, METHOD_NAME);
		
		request.addProperty(pi_name,pi_value);
		
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		envelope.dotNet = true;

		envelope.setOutputSoapObject(request);

		HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
		Object response = null;
		try {
			httpTransport.call(SOAP_ACTION, envelope);
			response = envelope.getResponse();
		} catch (Exception exception) {
			response = exception.toString();
		}
		return response.toString();
	}

}
